// Copyright 2009 Pigasus.
// GNU GPL v2.
// Author: John Zhang and Jordan Rupprecht.
//
// Defines the Job Thread, which is in change of pushes files and getting them
// back.
//
// Remember: compile using -pthread when using threads.

#ifndef JOBTHREADS_H_
#define JOBTHREADS_H_

#include "servers.h"
#include "pigasus-types.h"
#include "thread.h"

using namespace std;

// After all input files have been sent out, this is the number of seconds in
// between checking to see if they're all done.
const int kDefaultJobThreadDelay = 1;

// Threads of this type are for each job. The JobThread is responsible for
// sending each of the input cases out to a machine, checking to see which cases
// are done, marking a job as done if all cases are done, and retrieving the
// files for the done cases. Sending the files is done by spawning SendThreads.
// Retrieving files from remote servers is done by spawning GetThreads.
class JobThread : public Thread {
  Servers *servers;
  List *common;
  List *inputs;
  List *outputs;

 public:
  // 
  JobThread(Servers &servers_, List &common_, List &inputs_, List *outputs_);
  ~JobThread();

  void Run();  
};

#endif  // JOBTHREAD_H_
